package study.beancopy;

import lombok.*;
import org.springframework.beans.BeanUtils;

/**
 * @author study
 * @version 1.0
 * @date 2020/8/2 11:39
 */
public class BeanCopy {

    public static void main(String[] args) {
        Beans source = new Beans(1, "copy");
        Beans target = new Beans();
        BeanUtils.copyProperties(source, target);
        System.out.println(source);
        System.out.println(target);

        target.setName("copyTarget");
        System.out.println(source);
        System.out.println(target);

    }

}

@Data
@AllArgsConstructor
@NoArgsConstructor
class Beans {
    private Integer age;
    private String name;

}
